/* CodeBuilder代码生成器 创建时间：2011-11-04 00:27:25 */
using System;
using System.Data;
using System.Collections.Generic;
using Maticsoft.Common;

namespace BLL
{
    /// <summary>
    /// User
    /// </summary>
    public partial class User
    {
        private readonly DAL.User dal = new DAL.User();
        public User()
        { }
        #region  Method

        /// <summary>
        /// 是否存在该ID记录
        /// </summary>
        /// <param name="$Type">$Description</param>
        /// <returns>bool:True/False</returns>
        public bool Exists(Int32 ID)
        {
            return dal.Exists(ID);
        }

        /// <summary>
        /// 是否存在该条件记录
        /// </summary>
        /// <param name="strWhere">Where条件</param>
        /// <returns>bool:True/False</returns>
        public bool Exists(string strWhere)
        {
            return dal.Exists(strWhere);
        }

        /// <summary>
        /// 获取数量
        /// </summary>
        /// <returns>总记录数</returns>
        public int Count()
        {
            return dal.Count();
        }

        /// <summary>
        /// 根据条件获取数量
        /// </summary>
        /// <param name="strWhere">Where条件</param>
        /// <returns>记录数</returns>
        public int Count(string strWhere)
        {
            return dal.Count(strWhere);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">User实体对象</param>
        /// <returns>自动增长列</returns>
        public int Add(Model.User model)
        {
            return dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">User实体对象</param>
        /// <param name="strWhere">Where条件</param>
        /// <returns>修改条数</returns>
        public int Update(Model.User model, string strWhere)
        {
            return dal.Update(model, strWhere);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        /// <param name="Int32">主键</param>
        /// <returns>bool:True/False</returns>
        public bool Delete(Int32 ID)
        {
            return dal.Delete(ID);
        }
        /// <summary>
        /// 删除数据
        /// </summary>
        /// <param name="strWhere">Where条件</param>
        /// <returns>删除条数</returns>
        public int DeleteList(string strWhere)
        {
            return dal.DeleteList(strWhere);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.User GetModel(Int32 ID)
        {
            return dal.GetModel(ID);
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.User GetModel(string where)
        {
            return dal.GetModel(where);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        /// <param name="strWhere">Where条件</param>
        /// <returns>数据集</returns>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary>
        /// 获得前几行数据
        /// </summary>
        /// <param name="Top">条数</param>
        /// <param name="strWhere">Where条件</param>
        /// <param name="filedOrder">filedOrder排序</param>
        /// <returns>数据集</returns>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return dal.GetList(Top, strWhere, filedOrder);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Model.User> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Model.User> DataTableToList(DataTable dt)
        {
            List<Model.User> modelList = new List<Model.User>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Model.User model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Model.User();
                    if (dt.Rows[n]["ID"].ToString() != "")
                    {
                        model.ID = int.Parse(dt.Rows[n]["ID"].ToString());
                    }
                    if (dt.Rows[n]["UserName"].ToString() != "")
                    {
                        model.UserName = dt.Rows[n]["UserName"].ToString();
                    }
                    if (dt.Rows[n]["UserPassword"].ToString() != "")
                    {
                        model.UserPassword = dt.Rows[n]["UserPassword"].ToString();
                    }
                    if (dt.Rows[n]["Question"].ToString() != "")
                    {
                        model.Question = int.Parse(dt.Rows[n]["Question"].ToString());
                    }
                    if (dt.Rows[n]["Answer"].ToString() != "")
                    {
                        model.Answer = dt.Rows[n]["Answer"].ToString();
                    }
                    if (dt.Rows[n]["UserType"].ToString() != "")
                    {
                        model.UserType = int.Parse(dt.Rows[n]["UserType"].ToString());
                    }
                    if (dt.Rows[n]["Integral"].ToString() != "")
                    {
                        model.Integral = int.Parse(dt.Rows[n]["Integral"].ToString());
                    }
                    if (dt.Rows[n]["IsPass"].ToString() != "")
                    {
                        model.IsPass = bool.Parse(dt.Rows[n]["IsPass"].ToString());
                    }
                    if (dt.Rows[n]["NickName"].ToString() != "")
                    {
                        model.NickName = dt.Rows[n]["NickName"].ToString();
                    }
                    if (dt.Rows[n]["HeahImagePath"].ToString() != "")
                    {
                        model.HeahImagePath = dt.Rows[n]["HeahImagePath"].ToString();
                    }
                    if (dt.Rows[n]["Sex"].ToString() != "")
                    {
                        model.Sex = int.Parse(dt.Rows[n]["Sex"].ToString());
                    }
                    if (dt.Rows[n]["Age"].ToString() != "")
                    {
                        model.Age = int.Parse(dt.Rows[n]["Age"].ToString());
                    }
                    if (dt.Rows[n]["Occupation"].ToString() != "")
                    {
                        model.Occupation = dt.Rows[n]["Occupation"].ToString();
                    }
                    if (dt.Rows[n]["QQ"].ToString() != "")
                    {
                        model.QQ = dt.Rows[n]["QQ"].ToString();
                    }
                    if (dt.Rows[n]["MSN"].ToString() != "")
                    {
                        model.MSN = dt.Rows[n]["MSN"].ToString();
                    }
                    if (dt.Rows[n]["Height"].ToString() != "")
                    {
                        model.Height = dt.Rows[n]["Height"].ToString();
                    }
                    if (dt.Rows[n]["Tel"].ToString() != "")
                    {
                        model.Tel = dt.Rows[n]["Tel"].ToString();
                    }
                    if (dt.Rows[n]["Measurements"].ToString() != "")
                    {
                        model.Measurements = dt.Rows[n]["Measurements"].ToString();
                    }
                    if (dt.Rows[n]["Constellation"].ToString() != "")
                    {
                        model.Constellation = dt.Rows[n]["Constellation"].ToString();
                    }
                    if (dt.Rows[n]["signa"].ToString() != "")
                    {
                        model.signa = dt.Rows[n]["signa"].ToString();
                    }
                    if (dt.Rows[n]["AreaID"].ToString() != "")
                    {
                        model.AreaID = Int64.Parse(dt.Rows[n]["AreaID"].ToString());
                    }
                    if (dt.Rows[n]["NowInThe"].ToString() != "")
                    {
                        model.NowInThe = dt.Rows[n]["NowInThe"].ToString();
                    }
                    if (dt.Rows[n]["Looks"].ToString() != "")
                    {
                        model.Looks = dt.Rows[n]["Looks"].ToString();
                    }
                    if (dt.Rows[n]["LoveState"].ToString() != "")
                    {
                        model.LoveState = int.Parse(dt.Rows[n]["LoveState"].ToString());
                    }
                    if (dt.Rows[n]["Birth"].ToString() != "")
                    {
                        model.Birth = DateTime.Parse(dt.Rows[n]["Birth"].ToString());
                    }
                    if (dt.Rows[n]["School"].ToString() != "")
                    {
                        model.School = dt.Rows[n]["School"].ToString();
                    }
                    if (dt.Rows[n]["PhoneModel"].ToString() != "")
                    {
                        model.PhoneModel = dt.Rows[n]["PhoneModel"].ToString();
                    }
                    if (dt.Rows[n]["CardMumber"].ToString() != "")
                    {
                        model.CardMumber = dt.Rows[n]["CardMumber"].ToString();
                    }
                    if (dt.Rows[n]["LoveSnacks"].ToString() != "")
                    {
                        model.LoveSnacks = dt.Rows[n]["LoveSnacks"].ToString();
                    }
                    if (dt.Rows[n]["LoveStar"].ToString() != "")
                    {
                        model.LoveStar = dt.Rows[n]["LoveStar"].ToString();
                    }
                    if (dt.Rows[n]["LoveCuisines"].ToString() != "")
                    {
                        model.LoveCuisines = dt.Rows[n]["LoveCuisines"].ToString();
                    }
                    if (dt.Rows[n]["LoveMovie"].ToString() != "")
                    {
                        model.LoveMovie = dt.Rows[n]["LoveMovie"].ToString();
                    }
                    if (dt.Rows[n]["LikeObject"].ToString() != "")
                    {
                        model.LikeObject = dt.Rows[n]["LikeObject"].ToString();
                    }
                    if (dt.Rows[n]["MessObject"].ToString() != "")
                    {
                        model.MessObject = dt.Rows[n]["MessObject"].ToString();
                    }
                    if (dt.Rows[n]["VentObject"].ToString() != "")
                    {
                        model.VentObject = dt.Rows[n]["VentObject"].ToString();
                    }
                    if (dt.Rows[n]["LoveMusicStyle"].ToString() != "")
                    {
                        model.LoveMusicStyle = dt.Rows[n]["LoveMusicStyle"].ToString();
                    }
                    if (dt.Rows[n]["AddTime"].ToString() != "")
                    {
                        model.AddTime = DateTime.Parse(dt.Rows[n]["AddTime"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public Model.PageData GetList(int PageSize, int PageIndex, string strWhere, string sort)
        {
            return dal.GetList(PageSize, PageIndex, strWhere, sort);
        }

        #endregion  Method
    }
}

